package com.hansming.bss.modules.sfc.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.hansming.bss.common.service.CrudService;
import com.hansming.bss.modules.sfc.dao.PcUserDao;
import com.hansming.bss.modules.sfc.entity.PcUser;

@Service
@Transactional(readOnly = true)
public class PcUserService extends CrudService<PcUserDao,PcUser>{
	
	@Autowired
	private PcUserDao pcuserdao;
	
	@Transactional(readOnly = false)
	public int savepcuser(PcUser pcuser){
		return pcuserdao.savepcuser(pcuser);
	}
	
	//检测是否存在该电话的验证码
	public int checkphone(String phone){
		return pcuserdao.checkphone(phone);
	}
	
	@Transactional(readOnly = false)
	public int update(PcUser pcuser){
		return pcuserdao.update(pcuser);
	}
	
	
	public int checkcodephone (String phone){
		return pcuserdao.checkcodephone(phone);
	}
	
	//更新手机验证码
	@Transactional(readOnly = false)
	public void updatephonecode(String phone,String code,String codetime){
		pcuserdao.updatephonecode(phone, code, codetime);
	}
		
	//验证验证码
	public int checkphoneAndCode(String phone,String code){
		return pcuserdao.checkphoneAndCode(phone, code);
	}
	
	@Transactional(readOnly = false)
	public int	savephonecode(String phone,String code,String codetime){
		return pcuserdao.savephonecode(phone, code, codetime);
	}
	
	//根据电话号码查找出用户信息
	public String selectPcUserByPhone(String phone,String code){
		return pcuserdao.selectPcUserByPhone(phone,code);
	}
	
	
	public PcUser selectPcUserByPhoneAndCode(String phone,String code){
		return pcuserdao.selectPcUserByPhoneAndCode(phone, code);
	}
	
	public PcUser selectPcUserByPhoneAndPassword(String phone,String password){
		return pcuserdao.selectPcUserByPhoneAndPassword(phone, password);
	}
	
	@Transactional(readOnly = false)
	public int updatepassworedbyphone(String phone,String password){
		return pcuserdao.updatepassworedbyphone(phone, password);
	}
	
	
	//根据用户token查找用户
	public PcUser selectAllByToken(String token){
		return pcuserdao.selectAllByToken(token);
	}
}
